#include <iostream>
#include <sys/socket.h>
#include "socks/sock.h"

using namespace std;

void ex7()
{
	Sock breLoc(SOCK_DGRAM, (short)31470, 0);

	if (breLoc.good())
	{
		int desc = breLoc.getsDesc();

		sockaddr_in sAddr;
		socklen_t lgAddr = sizeof(sAddr);
		
		int res = getsockname(desc, (struct sockaddr*) &sAddr, &lgAddr);
		
		if (!res)
		{
			cout << "nom : " << ntohs(sAddr.sin_port) << endl;
		}
		else
		{
			cout << "pb getsockname" << endl;
		}

	}
	else
	{
		cout << "ERR : BR LOCAL" << endl;
	}
}

int main(int argc, char** argv)
{
	ex7();
	
	return 0;
}

